package com.it2297.controller;

import java.util.ArrayList;


import javax.swing.JOptionPane;

import com.it2297.model.Workshop;
import com.it2297.model.WorkshopParticipant;
import com.it2297.view.CreateWorkshopView;
import com.it2297.view.WorkshopParticipatedView;
import com.it2297.view.WorkshopView;

public class WorkshopParticipatedController {
	private WorkshopParticipatedView viewp;
	
	
	public WorkshopParticipatedController(WorkshopParticipatedView nv){
		this.viewp = nv;
	}
	
	public void CreateWorkshopParticipatedRecord() {
		
		WorkshopParticipant workshopp=new WorkshopParticipant();		
		workshopp.setParticipantId(viewp.getParticipantId());
		workshopp.setWorkshopId(viewp.getWorkshopId());
		workshopp.setTitle(viewp.getTitle());
		workshopp.setName(viewp.getName());
		workshopp.setNric(viewp.getNRIC());
		
		
		if(!WorkshopParticipant.IsWorkshopIdExists(viewp.getParticipantId())){
			workshopp.createWorkshopParticipant(workshopp);
			JOptionPane.showMessageDialog(null, "Successfully participated in event");
			}
			else
			{
				JOptionPane.showMessageDialog(null, "Duplicate participant_id!");
			}
	}
		public void UnjoinParticipatedWorkshop() {
			WorkshopParticipant workshopu=new WorkshopParticipant();
			workshopu.setParticipantId(viewp.getParticipantId());
			workshopu.delWorkshopJoined(workshopu);
			
		}
		
		
	}







